<template>
  <div>
    <div class="title">
      <span class="mr">设计师-{{ name }}</span>
      <span>现有积分: {{ num }}</span>
    </div>
    <!-- <div class="bottom mt">
      <el-form label-width="80px">
        <el-form-item label="检索日期:">
          <el-date-picker
            v-model="value1"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            @change="changeDate"
          />
        </el-form-item>
      </el-form> -->
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="created_at" label="时间" />
        <el-table-column prop="score" label="分数" />
        <el-table-column prop="user_name" label="操作人"></el-table-column>
        <el-table-column prop="record" label="备注" />
      </el-table>
    </div>
  </div>
</template>
<script>
import { getDesignerIntegral } from "@/api/http/designer";
export default {
  data() {
    return {
      id: 0,
      value1: [],
      start_at:"",
      end_at:"",
      name: "",
      num: 0,
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          circleUrl:
            "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
        }
      ]
    };
  },
  created() {
    if (this.$route.query.id) {
      this.id = this.$route.query.id;
      this.getDesignerIntegral();
    }
  },
  methods: {
    // 选择搜索时间
    changeDate(val) {
      console.log(val, "---val");
      this.start_at = val[0];
      this.end_at = val[1];
      this.getDesignerIntegral();
    },
    // 获取设计师积分记录数据
    getDesignerIntegral() {
      getDesignerIntegral({ id: this.id,start_at:this.start_at,end_at:this.end_at }).then(res => {
        if (res.code == 200) {
          console.log(res.data, "---99");
          this.tableData = res.data.bill;
          this.name = res.data.designer.name;
          this.num = res.data.designer.score;
          this.tableData.map(res => {
            res.user_name = this.name;
          });
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
@import "@/styles/el-table.scss";
@import "@/styles/color.scss";
.title {
  span {
    line-height: 44px;
    color: rgba(68, 68, 68, 1);
    font-size: 18px;
    text-align: center;
    font-family: Roboto;
    font-weight: bold;
  }
}
.mr {
  margin-right: 15px;
}
.mt {
  margin-top: 20px;
}
</style>
